/**
 * create by young (young2f@outlook.com) on 2020/12/4
 */
'use strict';
const model = require('../base/tModelBase');
const _ = require('lodash');
module.exports = app => {
  const mongoose = app.mongoose;
  const schema = mongoose.Schema;
  const connect = app.mongooseDB.get('pmcBus');
  const json = {
    treeId: { type: String, _type: 'code', title: '编码', required: true },
    recordId: { type: String, _type: 'code', title: '编码', required: true },
    name: { type: String, _type: 'string', title: '姓名', required: true, enableArea: [ 'table', 'detail', 'search' ] },
    date: { type: Date, _type: 'date', title: '日期', required: true, enableArea: [ 'table', 'detail', 'search' ] },
    matter: { type: String, _type: 'string', title: '事由', required: true, enableArea: [ 'table', 'detail', ] },
    rewards: { type: Number, _type: 'number', title: '奖励',  enableArea: [ 'table', 'detail', ] },
    Punishments: { type: Number, _type: 'number', title: '罚款',  enableArea: [ 'table', 'detail', ] },
    memo: { type: String, _type: 'memo', title: '备注', enableArea: [  'detail', ] },
    fileList: { type: Array, _type: 'fileList', title: '图片列表' },
  };
  const _model = _.cloneDeep(model);
  _.assign(_model, json);
  const _schema = new schema(
    _model,
    { timestamps: { createdAt: 'createdTs', updatedAt: 'updatedTs' } }
  );
  return connect.model('DicPerRewardsAndPunishments', _schema);
};
